package com.kucai.yifaqapp.presenter.activity;

import com.kucai.yifaqapp.global.HttpAdress;
import com.kucai.yifaqapp.model.CustomObserver;
import com.kucai.yifaqapp.model.network.HttpJsonUtils;
import com.kucai.yifaqapp.model.network.entity.res.ResIdearlist;
import com.kucai.yifaqapp.ui.activity.IdearrdActivity;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/12/9.api/m/feedbackList
 */

public class IdearrdActivityPresenter extends BaseActivityPresenter<IdearrdActivity> {
    public IdearrdActivityPresenter(IdearrdActivity mActivity) {
        super(mActivity);
    }


    /**
     * ‘status’: ‘’ //1未回复 2已回复
     * ‘startTime’ : ‘’//开始时间
     * ‘endTime’ : ‘’//结束时间
     */
    public void getidearlist(String token, String status, String starttime, String endtime) {
        HttpJsonUtils.getHttpApiInstance()
                .getidearlist(HttpAdress.getuseAdress() + "api/mobile/feedbackList",token, status, starttime, endtime)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CustomObserver<ResIdearlist>() {

                    @Override
                    protected void onCustomNext(ResIdearlist resIdearlist) {
                        if (resIdearlist.code == 0 && resIdearlist.data != null) {
                            mActivity.getlist(resIdearlist);
                        }
                    }

                    @Override
                    protected void onSubscribeCustom(Disposable disposable) {
                    }

                    @Override
                    protected void onErrorCustom(Throwable e) {

                    }
                });
    }
}
